package com.ruoyi.baoziyi.utils;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

public class FileUtil {
    //    获取文件夹内所有文件的名称
    public static List<String> listSubfolders(String folderPath){
        List<String> folderNames = new ArrayList<>();
        File folder = new File(folderPath);

        // 检查文件夹是否存在
        if (folder.exists() && folder.isDirectory()) {
            File[] subfolders = folder.listFiles();

            if (subfolders != null) {
                for (File subfolder : subfolders) {
                    folderNames.add(subfolder.getName());
                }
            }
        } else {
            System.err.println("指定的路径不是一个文件夹或文件夹不存在。");
        }
        return folderNames;
    }

}
